#include "stdafx.h"
#include "Model.h"
#include "VertexBuffer.h"
#include "ShaderContainer.h"
#include "GraphicsManager.h"

Model::Model(VertexBuffer* vBuffer)
{
	this->vBuffer = vBuffer;
}

Model::~Model(void)
{
	// release vertex buffer and material
	if (material)
		delete material;
	

	delete vBuffer;
}

/*virtual*/ void Model::setShaderContainer(ShaderContainer* value) /*override*/ 
{
	if (material && material->shaderContainer)
		delete material->shaderContainer;

	material->shaderContainer = value;
}

/*virtual*/ ShaderContainer* Model::getShaderContainer(void) const /*override*/
{
	return material->shaderContainer;
}

/*virtual*/ void Model::setResourceView(IGraphicsResource* value, unsigned int index) /*override*/
{
	material->textures.e[index] = value;
}